'use strict';

module.exports = appInfo => {
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1542163701470_4849';

  config.middleware = [ 'errorHandler', 'tokenValidate' ];

  config.errorHandler = {
    match: '/api',
  };

  config.tokenValidate = {};

  config.security = {
    csrf: {
      enable: false,
    },
    domainWhiteList: [ 'http://localhost:8000' ],
  };

  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    username: 'root',
    password: 'root',
    database: 'blue_v',
    port: 3306,
  };

  config.redis = {
    client: {
      host: '127.0.0.1', // Redis host
      port: 6379, // Redis port
      password: null,
      db: 0,
    },
  };

  config.jwt = {
    secret: '123456',
    enable: false,
  };

  config.bcrypt = {
    saltRounds: 10, // default 10
  };

  config.validate = {
    convert: false,
    validateRoot: false,
  };

  config.aliSMS = {
    client: {
      accessKeyId: 'yourAccessKeyId',
      secretAccessKey: 'yourAccessKeySecret',
      checkMobile: null, // check it work when this plugin init;
    },
  };

  config.multipart = {
    mode: 'file',
    cleanSchedule: {
      // run tmpdir clean job on every day 04:30 am
      // cron style see https://github.com/eggjs/egg-schedule#cron-style-scheduling
      cron: '0 30 4 * * *',
    },
  };

  config.swaggerdoc = {
    dirScanner: './app/controller',
    apiInfo: {
      title: 'egg-swagger',
      description: 'swagger-ui for egg',
      version: '1.0.0',
    },
    schemes: [ 'http', 'https' ],
    consumes: [ 'application/json' ],
    produces: [ 'application/json' ],
    enable: true,
  };

  return config;
};
